package com.jeecms.pay.core;

import com.jeecms.pay.constant.InnerExceptionEnum;
import com.jeecms.pay.constant.PayResultEnum;
import com.jeecms.pay.exception.PayClientException;
import com.jeecms.pay.exception.PayServerException;
import com.jeecms.pay.model.PayContext;
import com.jeecms.pay.model.PayInnerExceptionEntity;
import com.jeecms.pay.model.Result;
import com.jeecms.pay.util.ExceptionUtil;
import com.jeecms.pay.virtual.PayVirtual;

public class PayServiceInvoker {

	public static void invoke(PayContext context) {
		Result result = context.getResult();
		try {
			switch (context.getDevelopStageEnum()) {
			case junit:
				break;
			case virtual:
				PayVirtual.execute(context);
				break;
			case real:
				break;
			default:
				ExceptionUtil.throwServerEx("", context, InnerExceptionEnum.no_implements, null);
			}
		} catch (PayClientException clientEX) {
			PayInnerExceptionEntity entity = context.getPayInnerExceptionEntity();
			if (entity != null) {
				switch (entity.getInnerExceptionEnum()) {
				case input_para_error:
					result.setPayResultEnum(PayResultEnum.input_para_error);
					break;
				default:
					result.setPayResultEnum(PayResultEnum.no_implements);
				}
			}
		} catch (PayServerException serverEX) {
			// TODO
		} catch (Exception e) {
			// TODO
		}
	}

	private PayServiceInvoker() {

	}
}
